From 6d659d7442e486afe80a6c29f4ca41b757a01e2b Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 13 Nov 2007 17:28:44 +0000 Subject: [PATCH] Revert 16067:9f9f9b68cd08a03fc8cfad9f5ab702e50b6b6463. Signed-off-by: Keir Fraser --- xen/common/grant_table.c | 95 ++++++++++++---------------------------- 1 file changed, 29 insertions(+), 66 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 948df08a5e..1bd49523c3 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -198,7 +198,6 @@ __gnttab_map_grant_ref( int handle; unsigned long frame = 0; int rc = GNTST_okay; - int is_iomem = 0; struct active_grant_entry *act; struct grant_mapping *mt; grant_entry_t *sha; @@ -329,55 +328,34 @@ __gnttab_map_grant_ref( spin_unlock(&rd->grant_table->lock); - if ( op->flags & GNTMAP_host_map ) + if ( unlikely(!mfn_valid(frame)) || + unlikely(!((op->flags & GNTMAP_readonly) ? + get_page(mfn_to_page(frame), rd) : + get_page_and_type(mfn_to_page(frame), rd, + PGT_writable_page))) ) { - /* Could be an iomem page for setting up permission */ - if ( is_iomem_page(frame) ) - { - is_iomem = 1; - if ( iomem_permit_access(ld, frame, frame) ) - { - gdprintk(XENLOG_WARNING, - "Could not permit access to grant frame " - "%lx as iomem\n", frame); - rc = GNTST_general_error; - goto undo_out; - } - } - } - - if ( !is_iomem ) + if ( !rd->is_dying ) + gdprintk(XENLOG_WARNING, "Could not pin grant frame %lx\n", frame); + rc = GNTST_general_error; + goto undo_out; + } + + if ( op->flags & GNTMAP_host_map ) { - if ( unlikely(!mfn_valid(frame)) || - unlikely(!((op->flags & GNTMAP_readonly) ? - get_page(mfn_to_page(frame), rd) : - get_page_and_type(mfn_to_page(frame), rd, - PGT_writable_page)))) + rc = create_grant_host_mapping(op->host_addr, frame, op->flags); + if ( rc != GNTST_okay ) { - if ( !rd->is_dying ) - gdprintk(XENLOG_WARNING, - "Could not pin grant frame %lx\n", frame); - rc = GNTST_general_error; + if ( !(op->flags & GNTMAP_readonly) ) + put_page_type(mfn_to_page(frame)); + put_page(mfn_to_page(frame)); goto undo_out; } - - if ( op->flags & GNTMAP_host_map ) - { - rc = create_grant_host_mapping(op->host_addr, frame, op->flags); - if ( rc != GNTST_okay ) - { - if ( !(op->flags & GNTMAP_readonly) ) - put_page_type(mfn_to_page(frame)); - put_page(mfn_to_page(frame)); - goto undo_out; - } - if ( op->flags & GNTMAP_device_map ) - { - (void)get_page(mfn_to_page(frame), rd); - if ( !(op->flags & GNTMAP_readonly) ) - get_page_type(mfn_to_page(frame), PGT_writable_page); - } + if ( op->flags & GNTMAP_device_map ) + { + (void)get_page(mfn_to_page(frame), rd); + if ( !(op->flags & GNTMAP_readonly) ) + get_page_type(mfn_to_page(frame), PGT_writable_page); } } @@ -518,21 +496,12 @@ __gnttab_unmap_common( } } - if ( op->flags & GNTMAP_host_map ) + if ( (op->host_addr != 0) && (op->flags & GNTMAP_host_map) ) { - if ( (op->host_addr != 0) ) - { - if ( (rc = replace_grant_host_mapping(op->host_addr, - op->frame, op->new_addr, - op->flags)) < 0 ) - goto unmap_out; - } - else if ( is_iomem_page(op->frame) && - iomem_access_permitted(ld, op->frame, op->frame) ) - { - if ( (rc = iomem_deny_access(ld, op->frame, op->frame)) < 0 ) - goto unmap_out; - } + if ( (rc = replace_grant_host_mapping(op->host_addr, + op->frame, op->new_addr, + op->flags)) < 0 ) + goto unmap_out; ASSERT(act->pin & (GNTPIN_hstw_mask | GNTPIN_hstr_mask)); op->map->flags &= ~GNTMAP_host_map; @@ -540,7 +509,7 @@ __gnttab_unmap_common( act->pin -= GNTPIN_hstr_inc; else act->pin -= GNTPIN_hstw_inc; - } + } /* If just unmapped a writable mapping, mark as dirtied */ if ( !(op->flags & GNTMAP_readonly) ) @@ -1592,7 +1561,6 @@ gnttab_release_mappings( struct domain *rd; struct active_grant_entry *act; struct grant_entry *sha; - int rc; BUG_ON(!d->is_dying); @@ -1650,12 +1618,7 @@ gnttab_release_mappings( { BUG_ON(!(act->pin & GNTPIN_hstw_mask)); act->pin -= GNTPIN_hstw_inc; - - if ( is_iomem_page(act->frame) && - iomem_access_permitted(rd, act->frame, act->frame) ) - rc = iomem_deny_access(rd, act->frame, act->frame); - else - gnttab_release_put_page_and_type(mfn_to_page(act->frame)); + gnttab_release_put_page_and_type(mfn_to_page(act->frame)); } if ( (act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0 ) -- 2.30.2